package com.yuqian.tools;

import okhttp3.*;

import javax.print.attribute.standard.Media;
import javax.print.attribute.standard.MediaTray;
import java.io.IOException;

/**
 * Created by Administrator on 2017/8/1 0001.
 */
public class OffOnlineMessage {
    public static final MediaType JSON= MediaType.parse("application/json;charset=utf-8");

   static OkHttpClient client=new OkHttpClient();

    public static void addOffOnlineMessage(String infos){
        RequestBody Body=RequestBody.create(JSON,infos);
        FormBody formBody=new FormBody.Builder().add("infos",infos).build();
        Request request=new Request.Builder()
                .url("http://127.0.0.1:8080/newoffonline")
                .post(formBody)
                .build();
        try {
            Response response=client.newCall(request).execute();
            if (response.isSuccessful()){
                System.out.println("离线消息保存成功");

            }else {
                System.out.println("离线消息保存失败");
            }
        } catch (IOException e) {
            System.out.println("离线消息保存失败2");
            e.printStackTrace();
        }
    }


}
